home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5379 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  34 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!milyng
  3. From: mikael@pobox.com (Mikael Lyngvig)
  4. Subject: Re: error checking for int
  5. Message-ID: <milyngDM8Hvn.Jr5@netcom.com>
  6. Sender: milyng@netcom9.netcom.com
  7. Organization: Hacker's Paradise, Inc.
  8. X-Newsreader: WinVN 0.99.7
  9. References: <Pine.SUN.3.91.960203120230.12797A-100000@chip.bgsu.edu>
  10. Date: Sun, 4 Feb 1996 04:30:59 GMT
  11.  
  12. In article <Pine.SUN.3.91.960203120230.12797A-100000@chip.bgsu.edu>, 
  13. turner@chip.bgsu.edu says...
  14.  
  15. >        cout>>"\nEnter a number from 1-20: ";
  16. >        cin<<something[0];
  17.  
  18. Hmm.  Unless it is a typo, the problem is that you're reversing the operators.  
  19. The above should read:
  20.  
  21.    cout << "\nEnter a number from 1-20: ";
  22.    cin >> something[0];
  23.  
  24. I.e., "<<" should be ">>" and vice versa.
  25.  
  26. If that's not the problem, it may be that you need to dig a bit in the books 
  27. and find out how to query the stream objects for errors - I seem to recall 
  28. there's a member function called fail().  It might be useful (I don't use 
  29. streams myself, so I am not sure).
  30.  
  31.  
  32. Mikael
  33.  
  34.